package com.ncs.base.task.config;

import java.io.Serializable;
import java.util.List;

import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
import org.quartz.TriggerKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.ncs.base.common.rule.ApplicationContextUtil;
import com.ncs.base.task.entity.UserMasterEntity;
import com.ncs.base.task.service.UserMasterService;
import com.ncs.base.task.service.UserSalveService;

public class UserJob extends QuartzJobBean{
	

	
    @Override
    public void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {

    	UserMasterService userMasterService = (UserMasterService) ApplicationContextUtil.getBean("userMasterService");
    	UserSalveService userSalveService = (UserSalveService) ApplicationContextUtil.getBean("userSalveService");
    	
		JobDataMap triggerDataMap = jobExecutionContext.getTrigger().getJobDataMap();
		
    	String table = triggerDataMap.getString("tableName");
		
		List<UserMasterEntity> getuser = userMasterService.getuser(table);
		System.out.println("获取主表数据:"+table+"的"+getuser.size());
		
		userSalveService.SaveUserMasterList(getuser,table);
		System.out.println("插入从表数据:"+table+"的111");  
    }
}
